let _Base = null;

/**
 * applying multiple class mixins
 * 
 * example: 
 *      function A (Base=class {}){
 *          return class A extends Base{
 *             constructor(op={}){
 *                 super(op);
 *                 this.a=1;
 *                 this.b=23;
 *             }
 *         }
 *      }
 *      function B (Base=class {}){
 *          return class B extends Base{
 *              constructor(op={}){
 *                  super(op);
 *                  this.c=5;
 *                  this.d=9;
 *              }
 *          }
 *      }
 *      
 *      class C extends mix(THREE.Object3D)(A,B){
 *          constructor(op={}){
 *              super(op);
 *              this.e=111;
 *          }
 *      }
 */
const mixin=(...ms)=>{
    let Base=_Base||class Default {};
    _Base=null;
    let i=ms.length;
    let m;
    while(--i>=0){
        m=ms[i];
        Base=m(Base);
    }
    return Base;
};

export default function mix(Base){
    _Base=Base;
    return mixin;
}
